import request from '@/utils/request'

// 微信code换取微信openid
export function getOpenidByCode (code) {
  return request({
    url: '/selectOpenId',
    method: 'post',
    params: {
      code
    }
  })
}
// 检查是否手机号注册
export function checkAccount (params) {
  return request({
    url: '/selectUserAndOpenid',
    method: 'post',
    params
  })
}

// 发送手机验证码
export function sendMsg (params) {
  return request({
    url: '/sendSMS',
    method: 'post',
    params
  })
}

// 发送手机验证码
export function loadInfo (params) {
  return request({
    url: '/selectUserAndOpenid',
    method: 'post',
    params
  })
}

// 热门城市
export function loadHotCity (params) {
  return request({
    url: '/selectAllPoint',
    method: 'post',
    params
  })
}

// 注册
export function register (params) {
  return request({
    url: '/insertUser',
    method: 'post',
    params
  })
}

// 车主发布的消息
export function loadRouteList (params) {
  return request({
    url: '/selectOwnerList',
    method: 'post',
    params
  })
}

// 预定用户电话
export function loadUserPhone (params) {
  return request({
    url: '/selectUserById',
    method: 'post',
    params
  })
}

// 预定
export function Reserve (params) {
  return request({
    url: '/insertReserve',
    method: 'post',
    params
  })
}

// 预定
export function loadArticle (params) {
  return request({
    url: '/selectByConnect',
    method: 'post',
    params
  })
}

// 拉取车费
export function loadPeopleFree (params) {
  return request({
    url: '/selectAllPrice',
    method: 'post',
    params
  })
}
// 发布租车信息
export function postCar (params) {
  return request({
    url: '/insertOwner',
    method: 'post',
    params
  })
}

// 拉取城市json
export function loadCityList (params) {
  return request({
    url: '/static/mock/city.json',
    method: 'get',
    params
  })
}

// 认证驾驶证
export function driverConfirm (params) {
  console.log(params)
  let postParams = new FormData()
  postParams.append('driverCardA', params.driverCardA)
  return request({
    url: `/Authentication?id=${params.userId}`,
    method: 'post',
    data: postParams,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 认证行驶证
export function driverCardConfirm (params) {
  console.log(params)
  let postParams = new FormData()
  postParams.append('driverCardB', params.driverCardB)
  // postParams.append('name', params.name)
  // postParams.append('cardId', params.idcardNum)
  // postParams.append('userID', params.userId)
  return request({
    url: `/insertMotor?motorNum=${params.driverCardNum}&type=${params.carType}&id=${params.userId}`,
    method: 'post',
    data: postParams,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 认证身份证
export function userConfirm (params) {
  console.log(params)
  let postParams = new FormData()
  postParams.append('idcardZ', params.idcardZ)
  postParams.append('idcardB', params.idcardB)
  // postParams.append('name', params.name)
  // postParams.append('cardId', params.idcardNum)
  // postParams.append('userID', params.userId)
  return request({
    url: `/insertUserAuthorize?name=${params.name}&cardId=${params.idcardNum}&userID=${params.userId}`,
    method: 'post',
    data: postParams,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 修改手机号
export function updateTel (params) {
  return request({
    url: '/updatePhone',
    method: 'post',
    params
  })
}

// 修改用户名
export function updateName (params) {
  return request({
    url: '/updateName',
    method: 'post',
    params
  })
}

// 我的行程详情
export function loadReverInfo (params) {
  return request({
    url: '/selectAllReserve',
    method: 'post',
    params
  })
}

// 我的发布
export function loadReverseList (params) {
  return request({
    url: '/selectByReserve',
    method: 'post',
    params
  })
}

// 我的预约点击查 /insertUnsubscribe
export function loadOrderInfo (params) {
  return request({
    url: '/selectUserID',
    method: 'post',
    params
  })
}

// 退订座位
export function cancleOrder (params) {
  return request({
    url: '/insertUnsubscribe',
    method: 'post',
    params
  })
}

// 验证是否身份证认证
export function userIdAuthority (params) {
  return request({
    url: '/selectYzAuthorize',
    method: 'post',
    params
  })
}

// 验证是否驾驶证认证
export function driverIdAuthority (params) {
  return request({
    url: '/selectAuthentication',
    method: 'post',
    params
  })
}
// 验证是否行驶证认证
export function driverCardAuthority (params) {
  return request({
    url: '/selectByMotor',
    method: 'post',
    params
  })
}

// 城市
export function loadCitys (params) {
  return request({
    url: '/selectCountry',
    method: 'post',
    params
  })
}

// 城市帅选
export function searchCity (params) {
  return request({
    url: '/selectCountryMH',
    method: 'post',
    params
  })
}

// 支付
export function doPay (params) {
  return request({
    url: '/orders',
    method: 'post',
    params
  })
}

// 未支付订单添加
export function unpayInsert (params) {
  return request({
    url: '/insertAllZF',
    method: 'post',
    params
  })
}

// 判断车主是否有未支付的订单
export function unpayOrder (params) {
  return request({
    url: '/select',
    method: 'post',
    params
  })
}

// 订单所需钱数
export function payMoney (params) {
  return request({
    url: '/selectAll',
    method: 'post',
    params
  })
}

// 订单退订车主确认
export function cancleUserOrder (params) {
  return request({
    url: '/update',
    method: 'post',
    params
  })
}

// 支付成功之后给后端提示支付成功了
export function paySuccess (params) {
  return request({
    url: '/updateIsnong',
    method: 'post',
    params
  })
}

// 用户信息
export function customInfo (params) {
  return request({
    url: '/map',
    method: 'post',
    params
  })
}

// 用户信息
export function updatePublish (params) {
  return request({
    url: '/updateRelease',
    method: 'post',
    params
  })
}

// 无车的时候用户预约
export function nocarOrder (params) {
  return request({
    url: '/insertYy',
    method: 'post',
    params
  })
}
// 无车的时候用户预约列表
export function nocarOrderList (params) {
  return request({
    url: '/selectAllYy',
    method: 'post',
    params
  })
}
// 无车的时候预定列表修改预订信息
export function nocarOrderUpdate (params) {
  return request({
    url: '/updateYy',
    method: 'post',
    params
  })
}
// 无车的时候预定列表取消预订信息
export function nocarOrderCancle (params) {
  return request({
    url: '/updateZt',
    method: 'post',
    params
  })
}
// 无车的时候预定列表删除预订信息
export function nocarOrderDatele (params) {
  return request({
    url: '/deleteYy',
    method: 'post',
    params
  })
}
// 无车的时候预定列表删除预订信息
export function nocarOrderInfo (params) {
  return request({
    url: '/selectByUserIds',
    method: 'post',
    params
  })
}
